﻿<phone:PhoneApplicationPage
    x:Class="BookCaching.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:customControls="clr-namespace:BookCaching.CustomControls"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"                            
    xmlns:maps="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="commonPlaceItemTemplate">
            <customControls:GridID Tap="CommonPlaceItemTemplate_Tap" ID="{Binding ID}">
                <customControls:GridID.ColumnDefinitions>
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="*" />
                </customControls:GridID.ColumnDefinitions>
                <Image Grid.Row="0"
                       Grid.Column="0"
                       Height="70"
                       Width="50" 
                       Source="{Binding LogoImagePath}" />
                <TextBlock Grid.Row="0" 
                           Grid.Column="1"
                           TextWrapping="NoWrap"
                           FontSize="40"
                           Text="{Binding Name}"
                           Foreground="{Binding Source={StaticResource CurrentSettings}, Path=ForegroundColor, Mode=TwoWay}" />
            </customControls:GridID>
        </DataTemplate>

        <Style TargetType="maps:Pushpin" x:Key="PushpinBookStyle">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="maps:Pushpin">
                        <Image Source="/BookCaching;component/Images/pushpinBook.png" Stretch="None" VerticalAlignment="Center" HorizontalAlignment="Center"/>                                                                    
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Background" Value="Black" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontSize" Value="18" />
        </Style>

    </phone:PhoneApplicationPage.Resources>


    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:SlideTransition Mode="SlideDownFadeIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:SlideTransition Mode="SlideUpFadeIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:SlideTransition Mode="SlideUpFadeOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:SlideTransition Mode="SlideDownFadeOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{Binding Source={StaticResource CurrentSettings}, Path=BackgroundColor, Mode=TwoWay}">
        <controls:Panorama x:Name="panorama" >
            <controls:Panorama.Title>
                <Grid Margin="0, 80, 0, 0">
                    <Image Source="../Images/ribbonNonOfficial.png" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" />
                    <TextBlock Text="{Binding ConverterParameter=ApplicationTitle, Converter={StaticResource LocalizedStrings}, Source={StaticResource LocalizedStrings}}"
                               Foreground="{Binding Source={StaticResource CurrentSettings}, Path=ForegroundColor, Mode=TwoWay}" />
                </Grid>
            </controls:Panorama.Title>

            <!--Panorama item one-->
            <controls:PanoramaItem>
                <controls:PanoramaItem.Header>
                <TextBlock Text="{Binding ConverterParameter=MainPageProfileTitle, Converter={StaticResource LocalizedStrings}, Source={StaticResource LocalizedStrings}}"
                               Foreground="{Binding Source={StaticResource CurrentSettings}, Path=ForegroundColor, Mode=TwoWay}"/>
                </controls:PanoramaItem.Header>
                <Grid x:Name="userDataGrid"/>
            </controls:PanoramaItem>

            <!--Panorama item two-->
            <controls:PanoramaItem>
                <controls:PanoramaItem.Header>
                    <TextBlock Text="{Binding ConverterParameter=MainPageMapTitle, Converter={StaticResource LocalizedStrings}, Source={StaticResource LocalizedStrings}}"
                               Foreground="{Binding Source={StaticResource CurrentSettings}, Path=ForegroundColor, Mode=TwoWay}"/>
                </controls:PanoramaItem.Header>
                <Grid>
                    <maps:Map x:Name="map" 
                              CredentialsProvider="AgitESoE-WMP7OgKbfqXNpt1tfpvgly0K5FJH2Pxwj_zxVYeF4tvPQgpwe19vYnK" 
                              Mode="Road" 
                              Tap="Map_Tap" 
                              DoubleTap="Map_DoubleTap" 
                              ManipulationStarted="Map_ManipulationStarted" 
                              MapPan="Map_Pan" 
                              MapZoom="Map_Zoom" >
                        <maps:Pushpin x:Name="currentPositionPushpin"
                                      Background="{Binding Source={StaticResource CurrentSettings}, Path=ForegroundColor, Mode=TwoWay}"
                                      />
                        <maps:MapPolygon 
                            Fill="Black" Stroke="Black"
                            StrokeThickness="1"
                            Opacity="0.3"
                            x:Name="precision" />
                    </maps:Map>
                </Grid>
            </controls:PanoramaItem>

            <!--Panorama item three-->
            <controls:PanoramaItem>
                <controls:PanoramaItem.Header>
                    <TextBlock Text="{Binding ConverterParameter=MainPageCommonPlacesTitle, Converter={StaticResource LocalizedStrings}, Source={StaticResource LocalizedStrings}}"
                               Foreground="{Binding Source={StaticResource CurrentSettings}, Path=ForegroundColor, Mode=TwoWay}"/>
                </controls:PanoramaItem.Header>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    
                    <ScrollViewer Grid.Row="0">
                        <ListBox x:Name="commonPlacesListBox"
                                 ItemTemplate="{StaticResource commonPlaceItemTemplate}"/>
                    </ScrollViewer>
                    
                    <Button x:Name="allPlacesButton"
                            Grid.Row="1"
                            Click="AllPlacesButton_Click"
                            Style="{StaticResource ButtonInvertedColors}"
                            Content="{Binding ConverterParameter=AllPlacesButton, Converter={StaticResource LocalizedStrings}, Source={StaticResource LocalizedStrings}}"/>
                </Grid>
            </controls:PanoramaItem>
        </controls:Panorama>
    </Grid>

</phone:PhoneApplicationPage>